package com.sl.biz.modular.process.controller;

import com.sl.biz.modular.process.controller.request.*;
import com.sl.biz.modular.process.controller.response.ProcessVersionVO;
import com.sl.biz.modular.process.dao.domain.entity.ProcessVersionDO;
import com.sl.biz.modular.process.service.ProcessVersionContentBizService;
import com.sl.core.engine.check.ProcessCompCheckResult;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/process/version/content")
@RequiredArgsConstructor
public class ProcessVersionContentController {
    private final ProcessVersionContentBizService versionContentBizService;


    @PostMapping("/get_by_id")
    public ProcessVersionVO getById(@RequestBody @Validated ProcessVersionDO addRequest) {
        return versionContentBizService.getById(addRequest);
    }

    @PostMapping("/save_xml")
    public Boolean saveXml(@RequestBody @Validated SquareLakeProcessResourceAddRequest addRequest) {
        return versionContentBizService.saveXml(addRequest);
    }

    @PostMapping("/get_process_event_input_define")
    public Map<String, Object> getProcessEventInputDefine(@RequestBody @Validated SquareLakeProcessGetProcessInputDefineRequest addRequest) {
        return versionContentBizService.getProcessEventInputDefine(addRequest);
    }


    @PostMapping("/get_current_input_define")
    public Map<String, Object> getCurrentInputDefine(@RequestBody @Validated SquareLakeProcessGetCurrentInputDefineRequest addRequest) {
        return versionContentBizService.getCurrentInputDefine(addRequest);
    }

    @PostMapping("/get_current_output_define")
    public Map<String, Object> getCurrentOutputDefine(@RequestBody @Validated SquareLakeProcessGetCurrentOutputDefineRequest addRequest) {
        return versionContentBizService.getCurrentOutputDefine(addRequest);
    }
    @PostMapping("/get_next_transforms")
    public List<String> getNextTransforms(@RequestBody @Validated SquareLakeProcessGetNextTransformsRequest addRequest) {
        return versionContentBizService.getNextTransforms(addRequest);
    }

    @PostMapping("/build_scripts")
    public String buildScripts(@RequestBody @Validated SquareLakeProcessBuildScriptsRequest buildScriptsRequest) {
        return versionContentBizService.buildScripts(buildScriptsRequest);
    }

    @PostMapping("/check")
    public List<ProcessCompCheckResult> check(@RequestBody @Validated ProcessResourceCheckRequest checkRequest) {
        return versionContentBizService.check(checkRequest);
    }

    @PostMapping("/get_current_input_define_group")
    public List<Map<String, Object>>  getCurrentInputDefineGroup(@RequestBody @Validated SquareLakeProcessGetCurrentInputDefineGroupRequest checkRequest) {
        return versionContentBizService.getCurrentInputDefineGroup(checkRequest);
    }

}
